﻿using System.Drawing;
using System.Windows.Forms;

namespace WeifenLuo.WinFormsUI.Docking
{
    internal partial class DockAreasEditorControl : UserControl
    {
        private CheckBox checkBoxFloat;
        private CheckBox checkBoxDockLeft;
        private CheckBox checkBoxDockRight;
        private CheckBox checkBoxDockTop;
        private CheckBox checkBoxDockBottom;
        private CheckBox checkBoxDockFill;
        private DockAreas m_oldDockAreas;

        public DockAreasEditorControl()
        {
            InitializeComponent();
        }

        public DockAreas DockAreas
        {
            get
            {
                DockAreas dockAreas = 0;
                if (checkBoxFloat.Checked)
                    dockAreas |= DockAreas.Float;
                if (checkBoxDockLeft.Checked)
                    dockAreas |= DockAreas.DockLeft;
                if (checkBoxDockRight.Checked)
                    dockAreas |= DockAreas.DockRight;
                if (checkBoxDockTop.Checked)
                    dockAreas |= DockAreas.DockTop;
                if (checkBoxDockBottom.Checked)
                    dockAreas |= DockAreas.DockBottom;
                if (checkBoxDockFill.Checked)
                    dockAreas |= DockAreas.Document;

                if (dockAreas == 0)
                    return m_oldDockAreas;
                else
                    return dockAreas;
            }
        }

        public void SetStates(DockAreas dockAreas)
        {
            m_oldDockAreas = dockAreas;
            if ((dockAreas & DockAreas.DockLeft) != 0)
                checkBoxDockLeft.Checked = true;
            if ((dockAreas & DockAreas.DockRight) != 0)
                checkBoxDockRight.Checked = true;
            if ((dockAreas & DockAreas.DockTop) != 0)
                checkBoxDockTop.Checked = true;
            if ((dockAreas & DockAreas.DockTop) != 0)
                checkBoxDockTop.Checked = true;
            if ((dockAreas & DockAreas.DockBottom) != 0)
                checkBoxDockBottom.Checked = true;
            if ((dockAreas & DockAreas.Document) != 0)
                checkBoxDockFill.Checked = true;
            if ((dockAreas & DockAreas.Float) != 0)
                checkBoxFloat.Checked = true;
        }
    }
}